#-*- coding: utf8 -*-
from tutor.scripts import *
from tutor.plugins.sympy import *

while True:
    with display_block('Entradas'):
        a = sqrt(rfraction(6, force_pos=True))
        b = sqrt(rfraction(6, force_pos=True))
        S = a ** 2 / 4 + b ** 2
        az = a * z
        if not issimple(S, 5):
            continue

    with display_block('Resultados'):
        resps = [b, (4 * b ** 2 + a ** 2) / (4 * a)]
        resps.sort()
        resps.append(0)

        for frac in rfractions(force_pos=True, max_size=30):
            if len(resps) >= 8:
                break
            new = oneof(*resps) * frac
            if new not in resps:
                frac = (new.args[0] if type(new) is Mul else new)
                if issimple(frac, 5):
                    resps.append(new)

        try:
            correta, outro, zero, distr1, distr2, distr3, distr4, distr5 = resps
        except ValueError:
            continue
        else:
            break
